#!/bin/bash

# 原始HTTP响应捕获脚本
echo "🎯 原始HTTP响应捕获工具"
echo "======================"

# 检查Python环境
if ! command -v python3 &> /dev/null; then
    echo "❌ Python3 未找到，请安装Python3"
    exit 1
fi

# 检查依赖
echo "📦 检查依赖..."
python3 -c "import httpx, asyncio" 2>/dev/null
if [ $? -ne 0 ]; then
    echo "❌ 缺少依赖包，请安装: pip install httpx"
    exit 1
fi

echo "✅ 依赖检查通过"

# 生成输出文件名
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
OUTPUT_FILE="raw_http_response_${TIMESTAMP}.txt"

echo "🚀 开始捕获原始HTTP响应..."
echo "📁 输出文件: ${OUTPUT_FILE}"

# 运行捕获脚本
cd "$(dirname "$0")"
python3 capture_raw_http_clean.py > "../${OUTPUT_FILE}" 2>&1

if [ $? -eq 0 ]; then
    echo "✅ 捕获完成"
    echo "📊 文件大小: $(ls -lh "../${OUTPUT_FILE}" | awk '{print $5}')"
    echo "📖 查看文件: cat ${OUTPUT_FILE}"
    echo "🔍 查看前20行: head -20 ${OUTPUT_FILE}"
else
    echo "❌ 捕获失败，请检查错误信息"
fi 